﻿<Page x:Class="DatabaseToolsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Database Tools" AllowDrop="True">
    <StackPanel Style="{StaticResource AppFont}">
        <TextBlock Style="{StaticResource PageTitle}">Database Tools</TextBlock>
        <FlowDocumentScrollViewer Style="{StaticResource FlowDocumentScrollViewerStyle}" MaxWidth="800">
            <FlowDocument>
                <BlockUIContainer>
                    <StackPanel AllowDrop="True">
                        <TextBlock TextWrapping="Wrap">
                            <Bold>Create Database:</Bold> This tool performs a basic check to ensure that the tables used by the
                            application are present in the database. It does NOT perform a detailed
                            verification of those tables.
                        </TextBlock>

                        <StackPanel Orientation="Horizontal">
                            <Button Name="btnCheckDatabase" Margin="10">Check Database</Button>
                            <Label Name="lblCheckDatabaseStatus" Style="{StaticResource LabelStatusOkay}" Margin="10">
                                <TextBlock>
                                    <Run>The database hasn't been checked.</Run>
                                </TextBlock>
                            </Label>
                        </StackPanel>

                        <TextBlock TextWrapping="Wrap">
                            <Bold>Create Database:</Bold> This tool will create a new set of tables using the current connection.
                            Some of these tables hold user data that gets added to the spatial catalog
                            when images are loaded (Photo, Album).
                            The other tables will be preloaded with data that supports the application (TimeZone, City, County,
                            and State). Any existing tables with these names will be dropped and then recreated.
                            It can take several minutes to load the support tables. They contain about 45,000 rows,
                            40,000 of which are in the City table.
                            The data in the Album table can be saved before the table is dropped, and then reloaded afterwards.
                        </TextBlock>
                        <StackPanel Orientation="Horizontal">
                            <Button Name="btnCreateDatabase" Margin="10">Create Database</Button>
                            <CheckBox Name="cbxKeepAlbumData"  IsChecked="True"  VerticalAlignment="Center" Margin="10">Keep album data</CheckBox>
                            <Label Name="lblCreateDatabaseStatus" VerticalAlignment="Center" Style="{StaticResource LabelStatusOkay}" Margin="10">Database reload not started.</Label>
                        </StackPanel>
                        <TextBlock TextWrapping="Wrap">
                            <Bold>Load Three Images:</Bold> Use this tool to load three sample images into the database.
                            These images are distributed with the application. You should not need to locate them.
                            Check the log for any errors that may be reported.
                        </TextBlock>
                        <StackPanel Orientation="Horizontal">
                            <Button Name="btnLoadSamples" Margin="10">Load Three Images</Button>
                            <Label Name="lblLoadSamplesStatus" Style="{StaticResource LabelStatusOkay}" Margin="10">Not loaded.</Label>
                        </StackPanel>
                        <TextBlock TextWrapping="Wrap">
                            <Bold>Clear Photo Table:</Bold> This tool will delete all rows from the Photos table.
                        </TextBlock>
                        <StackPanel Orientation="Horizontal">
                            <Button Name="btnClearPhotos" Margin="10">Clear Photos</Button>
                            <Label Name="lblClearPhotosStatus" Style="{StaticResource LabelStatusOkay}" Margin="10">Not cleared.</Label>
                        </StackPanel>
                        <WrapPanel>
                            <TextBlock VerticalAlignment="Center"><Bold>Database Statistics</Bold></TextBlock>
                            <Button Margin="20,0,0,0" VerticalAlignment="Center" Name="btnRefreshStatistics">Refresh</Button>
                        </WrapPanel>
                        <FlowDocumentScrollViewer Style="{StaticResource FlowDocumentScrollViewerStyle}">
                            <FlowDocument>
                                <Table Name="StatisticsTable1">
                                    <TableRowGroup>
                                        <TableRow>
                                            <TableCell>
                                                <Paragraph>Press the "Refresh" button.</Paragraph>
                                            </TableCell>
                                        </TableRow>
                                    </TableRowGroup>
                                </Table>
                            </FlowDocument>
                        </FlowDocumentScrollViewer>
                    </StackPanel>
                </BlockUIContainer>
            </FlowDocument>
        </FlowDocumentScrollViewer>
    </StackPanel>
</Page>
